package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;

import java.util.Arrays;

/**
 * 滤芯复位与修改：
 * 必须绑定套餐后操作，否则无响应。
 * 接收应答一致：
 *
 */
public class FilterUpdateMessage extends ProtocolMessage {

    /** 标记码1 */
    private byte code1;
    /** 标记码2 */
    private byte code2;
    /** 标记码3 */
    private byte code3;

    public byte getCode1() {
        return code1;
    }

    public void setCode1(byte code1) {
        this.code1 = code1;
    }

    public byte getCode2() {
        return code2;
    }

    public void setCode2(byte code2) {
        this.code2 = code2;
    }

    public byte getCode3() {
        return code3;
    }

    public void setCode3(byte code3) {
        this.code3 = code3;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeByte(this.code1);
        this.byteArray.writeByte(this.code2);
        this.byteArray.writeByte(this.code3);
    }

    @Override
    public void onDeserialize() {
        this.code1 = this.byteArray.readByte();
        this.code2 = this.byteArray.readByte();
        this.code3 = this.byteArray.readByte();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("FilterUpdateMessage{");
        sb.append("code1=").append(code1);
        sb.append(", code2=").append(code2);
        sb.append(", code3=").append(code3);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
